package com.ruoyi.roomType.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.roomType.domain.ReserveMain;
import com.ruoyi.roomType.service.IReserveMainService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 预订主表Controller
 * 
 * @author ruoyi
 * @date 2025-05-09
 */
@RestController
@RequestMapping("/manage/reserve_main")
public class ReserveMainController extends BaseController
{
    @Autowired
    private IReserveMainService reserveMainService;

    /**
     * 查询预订主表列表
     */
    @PreAuthorize("@ss.hasPermi('manage:reserve_main:list')")
    @GetMapping("/list")
    public TableDataInfo list(ReserveMain reserveMain)
    {
        startPage();
        List<ReserveMain> list = reserveMainService.selectReserveMainList(reserveMain);
        return getDataTable(list);
    }

    /**
     * 导出预订主表列表
     */
    @PreAuthorize("@ss.hasPermi('manage:reserve_main:export')")
    @Log(title = "预订主表", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ReserveMain reserveMain)
    {
        List<ReserveMain> list = reserveMainService.selectReserveMainList(reserveMain);
        ExcelUtil<ReserveMain> util = new ExcelUtil<ReserveMain>(ReserveMain.class);
        util.exportExcel(response, list, "预订主表数据");
    }

    /**
     * 获取预订主表详细信息
     */
    @PreAuthorize("@ss.hasPermi('manage:reserve_main:query')")
    @GetMapping(value = "/{reserveId}")
    public AjaxResult getInfo(@PathVariable("reserveId") Long reserveId)
    {
        return success(reserveMainService.selectReserveMainByReserveId(reserveId));
    }

    /**
     * 新增预订主表
     */
    @PreAuthorize("@ss.hasPermi('manage:reserve_main:add')")
    @Log(title = "预订主表", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ReserveMain reserveMain)
    {
        return toAjax(reserveMainService.insertReserveMain(reserveMain));
    }

    /**
     * 修改预订主表
     */
    @PreAuthorize("@ss.hasPermi('manage:reserve_main:edit')")
    @Log(title = "预订主表", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ReserveMain reserveMain)
    {
        return toAjax(reserveMainService.updateReserveMain(reserveMain));
    }

    /**
     * 删除预订主表
     */
    @PreAuthorize("@ss.hasPermi('manage:reserve_main:remove')")
    @Log(title = "预订主表", businessType = BusinessType.DELETE)
	@DeleteMapping("/{reserveIds}")
    public AjaxResult remove(@PathVariable Long[] reserveIds)
    {
        return toAjax(reserveMainService.deleteReserveMainByReserveIds(reserveIds));
    }
}
